﻿
Imports System.Data.OleDb
Imports System.ServiceModel
Imports System.ServiceModel.Syndication
Imports System.Xml




Public Class rss
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.ContentType = "application/rss+xml"

        Dim rss As New SyndicationFeed

        rss.Title = TextSyndicationContent.CreatePlaintextContent("Most Recent Photo Sharing Apps")

        rss.Description = TextSyndicationContent.CreatePlaintextContent("Most Recent Photo Sharing AppsList in the website")

        rss.Links.Add(SyndicationLink.CreateSelfLink(New Uri(okURL("Default.aspx"))))

        rss.Language = "en-uk"

        Dim oleDbConn As New OleDbConnection(ConfigurationManager.ConnectionStrings("IslandConnectionString").ConnectionString)

        oleDbConn.Open()

        Dim cmdQuery As String = "select * from  tour"

        Dim dbcomm = New OleDbCommand(cmdQuery, oleDbConn)

        Dim readDB As OleDbDataReader

        readDB = dbcomm.ExecuteReader()

        Dim items As New List(Of SyndicationItem)

        While readDB.Read()

            Dim sItem As New SyndicationItem


            sItem.Title = mkRssTxt(readDB("IslandName"))

            sItem.Summary = mkRssTxt(readDB("Postcode"))

            items.Add(sItem)

        End While

        rss.Items = items

        Dim writerss As XmlWriter = XmlWriter.Create(Response.OutputStream)

        Dim formatrss = New Rss20FeedFormatter(rss)

        formatrss.WriteTo(writerss)

        writerss.Close()



    End Sub

    Private Function mkRssTxt(ByVal someString As String) As TextSyndicationContent

        Return TextSyndicationContent.CreatePlaintextContent(someString)

    End Function

    Private Function okURL(ByVal urlStr As String)

        Return Request.Url.GetLeftPart(UriPartial.Authority) & ResolveUrl(urlStr)

    End Function


End Class

